/* common.js */

// Namespace object =======================================================================================================================
var AV = {};

// Date/Time Clock (Singleton) ============================================================================================================
AV.getDate = new function() 
{

	var dayArray = new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");
	var monthArray = new Array("January","February","March","April","May","June","July","August","September","October","November","December");

	this.write = function(elId) 
	{
		var obj = document.getElementById(elId);
		
		if (!obj) 
		{ 
			window.setTimeout( function() { AV.getDate.write(elId); }, 1000); 
			return;
		}
		
		var myDate = new Date();
		var year = myDate.getFullYear()
		var day = myDate.getDay();
		var month = myDate.getMonth();
		var date = myDate.getDate();
		var hours = myDate.getHours()
		var minutes = myDate.getMinutes()
		var dn="AM"
		
		if (year < 1000) { year += 1900; }
		if (date < 10) { date = "0" + date; }
		if (hours >= 12) { dn = "PM"; }
		if (hours > 12) { hours = hours - 12; }
		if (hours == 0) { hours = 12; }
		if (minutes <= 9) { minutes = "0" + minutes; }
	
		var fullDate = dayArray[day] + ", " + monthArray[month] + " " + date + ", " + year + " | " + hours + ":" + minutes + " " + dn;
	
		obj.innerHTML = fullDate;
		
		setTimeout( function() { AV.getDate.write(elId); }, 10000)
	}
	
}();

// File Types =============================================================================================================================
AV.FileTypes = new function()
{
	return {
		Image	: ['gif', 'jpeg', 'jpg', 'png', 'bmp'],
		Flash	: ['swf'],
		Doc		: ['doc', 'docx', 'htm', 'html', 'xls', 'xlsx', 'pdf', 'pps', 'ppsx', 'ppt', 'pptx', 'txt', 'rtf', 'zip', 'wma', 'vcf'],
		Video	: ['avi', 'mov', 'mpeg', 'mpg', 'wmv'],
		FLV		: ['flv'], 
	
		isType: function(sFileName, arTypes)
		{
			var arParts = sFileName.split('.');
			var sExt = arParts[arParts.length - 1].toLowerCase();
			var iLen = arTypes.length;
			
			for (var i=0; i<iLen; i++)
			{
				if (arTypes[i] == sExt) return true;
			}
			return false;
		}, 
		
		getType: function(sFileName)
		{
			var arParts = sFileName.split('.');
			var sExt = arParts[arParts.length - 1].toLowerCase();

			if (sExt == 'flv') return 'FLV';

			for (var i=(this.Image.length - 1); i>-1; i--)
			{
				if (this.Image[i] == sExt) return 'Image';
			}
			
			for (var i=(this.Flash.length - 1); i>-1; i--)
			{
				if (this.Flash[i] == sExt) return 'Flash';
			}
			
			for (var i=(this.Video.length - 1); i>-1; i--)
			{
				if (this.Video[i] == sExt) return 'Video';
			}
			
			for (var i=(this.Doc.length - 1); i>-1; i--)
			{
				if (this.Doc[i] == sExt) return 'Doc';
			}						
			
			return false;
		}
	}
}

AV.FormatFileName = function(strFileName)
{
	var x = strFileName;
	x = x.replace(/\*/g, "");      // delete *
	x = x.replace(/\[/g, "");      // delete [
	x = x.replace(/\]/g, "");      // delete ]
	x = x.replace(/\</g, "");      // delete <
	x = x.replace(/\>/g, "");      // delete >
	x = x.replace(/\=/g, "");      // delete =
	x = x.replace(/\+/g, "");      // delete +
	x = x.replace(/\'/g, "");      // delete '
	x = x.replace(/\"/g, "");      // delete "
	x = x.replace(/\\/g, "");      // delete \
	x = x.replace(/\//g, "");      // delete /
	x = x.replace(/\,/g, "");      // delete ,
	x = x.replace(/\./g, "");      // delete .
	x = x.replace(/\:/g, "");      // delete :
	x = x.replace(/\;/g, "");      // delete ;
	//x = x.replace(/ /g, "");         // delete spaces
	return x;
}

// Returns an attribute value for a given string and attribute name
// will fine attr=test, attr='test', and attr="test some More"
AV.GetAttribute = function(strIn, attName)
{
	function findNext(strFind, chr)
	{
		var iLen = strFind.length;
		for (var i=0; i<iLen; i++)
		{
			if (strFind.charAt(i) == chr)
			{
				if (i==iLen || chr == " ") { return i; }
				else if (strFind.charAt(i+1) == " " || strFind.charAt(i+1) == ">") { return i; }
			}
		}
		return -1;
	}
	
	var iAttStart = 0, iAttEnd = 0;
	if (attName.charAt(attName.length - 1) != "=") { attName += "="; }
	
	iAttStart = strIn.toLowerCase().indexOf(attName.toLowerCase());
	if (iAttStart == -1) { return ""; }
	else { iAttStart += attName.length; }
	
	var sAttRaw = strIn.substr(iAttStart);
	switch (sAttRaw.substring(0,1))
	{
		case "'":
			iAttStart++;
			iAttEnd = findNext(sAttRaw.substr(1), "'");
			break;
			
		case '"':
			iAttStart++;
			iAttEnd = findNext(sAttRaw.substr(1), '"');
			break;
			
		default:
			iAttEnd = findNext(sAttRaw, ' ');	
	}
	
	if (iAttEnd == -1) return "";
	else { return strIn.substring(iAttStart, (iAttStart + iAttEnd)); }
}

ns4 = (document.layers);
ie4 = (document.all);
var UPWindow;
var sPrefix = "/";

    // convert all characters to lowercase to simplify testing
    var agt=navigator.userAgent.toLowerCase();

    // *** BROWSER VERSION ***
    // Note: On IE5, these return 4, so use is.ie5up to detect IE5.
    var is_major = parseInt(navigator.appVersion);
    var is_minor = parseFloat(navigator.appVersion);
    var is_dom   = (document.getElementById) ? "true" : "false"; // 001121-abk

    var is_nav  = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1)
                && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1)
                && (agt.indexOf('webtv')==-1));
    var is_nav2 = (is_nav && (is_major == 2));
    var is_nav3 = (is_nav && (is_major == 3));
    var is_nav4 = (is_nav && (is_major == 4));
    var is_nav4up = (is_nav && (is_major >= 4));
    var is_navonly      = (is_nav && ((agt.indexOf(";nav") != -1) ||
                          (agt.indexOf("; nav") != -1)) );
	var is_nav6 = (is_nav && (agt.indexOf('netscape6') != -1)); // new 001120 - abk
	var is_nav6up = (is_nav && is_dom);                         // new 001121 - abk
    var is_nav5 = (is_nav && (is_major == 5) && !(is_nav6)); // checked for ns6
    var is_nav5up = (is_nav && (is_major >= 5));
	
	// how to check for ns7+? is_major is still 5 in ns6 - abk
	
    var is_ie   = (agt.indexOf("msie") != -1);
    var is_ie3  = (is_ie && (is_major < 4));

// allow for v6+ ie
 
var msie_vers_start = agt.indexOf("msie")+5;
var msie_real_vers = parseFloat(agt.substring(msie_vers_start, msie_vers_start+3));

//    var is_ie4  = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.")==-1));

    var is_ie4  = (is_ie && (is_major == 4) && (msie_real_vers < 5));

    var is_ie4up  = (is_ie  && (is_major >= 4));
//    var is_ie5  = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.")!=-1));

    var is_ie5  = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.")!=-1));

    var is_ie5up  = (is_ie  && !is_ie3 && !is_ie4);

// KNOWN BUG: On AOL4, returns false if IE3 is embedded browser 
    // or if this is the first browser window opened.  Thus the 
    // variables is_aol, is_aol3, and is_aol4 aren't 100% reliable. 
    
    var is_aol   = (agt.indexOf("aol") != -1);
    var is_aol3  = (is_aol && is_ie3);
    var is_aol4  = (is_aol && is_ie4);

    var is_opera = (agt.indexOf("opera") != -1);
    var is_webtv = (agt.indexOf("webtv") != -1);

    // *** JAVASCRIPT VERSION CHECK ***
    // Useful to workaround Nav3 bug in which Nav3
    // loads <SCRIPT LANGUAGE="JavaScript1.2">.
    var is_js;
    if (is_nav2 || is_ie3) is_js = 1.0
    else if (is_nav3 || is_opera) is_js = 1.1
    else if ((is_nav4 && (is_minor <= 4.05)) || is_ie4) is_js = 1.2
    else if ((is_nav4 && (is_minor > 4.05)) || is_ie5) is_js = 1.3
    else if (is_nav5 && !(is_nav6)) is_js = 1.4
    else if (is_nav6) is_js = 1.5
    
    // NOTE: In the future, update this code when newer versions of JS
    // are released. For now, we try to provide some upward compatibility
    // so that future versions of Nav and IE will show they are at
    // *least* JS 1.x capable. Always check for JS version compatibility
    // with > or >=.
    
    else if (is_nav && (is_major > 5)) is_js = 1.4
    else if (is_ie && (is_major > 5)) is_js = 1.3
    // HACK: no idea for other browsers; always check for JS version with > or >=
    else is_js = 0.0;

    // *** PLATFORM ***
    var is_win   = ( (agt.indexOf("win")!=-1) || (agt.indexOf("16bit")!=-1) );
    // NOTE: On Opera 3.0, the userAgent string includes "Windows 95/NT4" on all
    //        Win32, so you can't distinguish between Win95 and WinNT.
    var is_win95 = ((agt.indexOf("win95")!=-1) || (agt.indexOf("windows 95")!=-1));

    // is this a 16 bit compiled version?
    var is_win16 = ((agt.indexOf("win16")!=-1) || 
               (agt.indexOf("16bit")!=-1) || (agt.indexOf("windows 3.1")!=-1) || 
               (agt.indexOf("windows 16-bit")!=-1) );  

    var is_win31 = ((agt.indexOf("windows 3.1")!=-1) || (agt.indexOf("win16")!=-1) ||
                    (agt.indexOf("windows 16-bit")!=-1));

    // NOTE: Reliable detection of Win98 may not be possible. It appears that:
    //       - On Nav 4.x and before you'll get plain "Windows" in userAgent.
    //       - On Mercury client, the 32-bit version will return "Win98", but
    //         the 16-bit version running on Win98 will still return "Win95".
    var is_win98 = ((agt.indexOf("win98")!=-1) || (agt.indexOf("windows 98")!=-1));
    var is_winnt = ((agt.indexOf("winnt")!=-1) || (agt.indexOf("windows nt")!=-1));
    var is_win32 = (is_win95 || is_winnt || is_win98 || 
                    ((is_major >= 4) && (navigator.platform == "Win32")) ||
                    (agt.indexOf("win32")!=-1) || (agt.indexOf("32bit")!=-1));

    var is_os2   = ((agt.indexOf("os/2")!=-1) || 
                    (navigator.appVersion.indexOf("OS/2")!=-1) ||   
                    (agt.indexOf("ibm-webexplorer")!=-1));

    var is_mac    = (agt.indexOf("mac")!=-1);
    var is_mac68k = (is_mac && ((agt.indexOf("68k")!=-1) || 
                               (agt.indexOf("68000")!=-1)));
    var is_macppc = (is_mac && ((agt.indexOf("ppc")!=-1) || 
                                (agt.indexOf("powerpc")!=-1)));

    var is_sun   = (agt.indexOf("sunos")!=-1);
    var is_sun4  = (agt.indexOf("sunos 4")!=-1);
    var is_sun5  = (agt.indexOf("sunos 5")!=-1);
    var is_suni86= (is_sun && (agt.indexOf("i86")!=-1));
    var is_irix  = (agt.indexOf("irix") !=-1);    // SGI
    var is_irix5 = (agt.indexOf("irix 5") !=-1);
    var is_irix6 = ((agt.indexOf("irix 6") !=-1) || (agt.indexOf("irix6") !=-1));
    var is_hpux  = (agt.indexOf("hp-ux")!=-1);
    var is_hpux9 = (is_hpux && (agt.indexOf("09.")!=-1));
    var is_hpux10= (is_hpux && (agt.indexOf("10.")!=-1));
    var is_aix   = (agt.indexOf("aix") !=-1);      // IBM
    var is_aix1  = (agt.indexOf("aix 1") !=-1);    
    var is_aix2  = (agt.indexOf("aix 2") !=-1);    
    var is_aix3  = (agt.indexOf("aix 3") !=-1);    
    var is_aix4  = (agt.indexOf("aix 4") !=-1);    
    var is_linux = (agt.indexOf("inux")!=-1);
    var is_sco   = (agt.indexOf("sco")!=-1) || (agt.indexOf("unix_sv")!=-1);
    var is_unixware = (agt.indexOf("unix_system_v")!=-1); 
    var is_mpras    = (agt.indexOf("ncr")!=-1); 
    var is_reliant  = (agt.indexOf("reliantunix")!=-1);
    var is_dec   = ((agt.indexOf("dec")!=-1) || (agt.indexOf("osf1")!=-1) || 
           (agt.indexOf("dec_alpha")!=-1) || (agt.indexOf("alphaserver")!=-1) || 
           (agt.indexOf("ultrix")!=-1) || (agt.indexOf("alphastation")!=-1)); 
    var is_sinix = (agt.indexOf("sinix")!=-1);
    var is_freebsd = (agt.indexOf("freebsd")!=-1);
    var is_bsd = (agt.indexOf("bsd")!=-1);
    var is_unix  = ((agt.indexOf("x11")!=-1) || is_sun || is_irix || is_hpux || 
                 is_sco ||is_unixware || is_mpras || is_reliant || 
                 is_dec || is_sinix || is_aix || is_linux || is_bsd || is_freebsd);

    var is_vms   = ((agt.indexOf("vax")!=-1) || (agt.indexOf("openvms")!=-1));
// additional checks, abk
	var is_anchors = (document.anchors) ? "true":"false";
	var is_regexp = (window.RegExp) ? "true":"false";
	var is_option = (window.Option) ? "true":"false";
	var is_all = (document.all) ? "true":"false";
// cookies - 990624 - abk
	document.cookie = "cookies=true";
	var is_cookie = (document.cookie) ? "true" : "false";
	var is_images = (document.images) ? "true":"false";
	var is_layers = (document.layers) ? "true":"false"; // gecko m7 bug?
// new doc obj tests 990624-abk
	var is_forms = (document.forms) ? "true" : "false";
	var is_links = (document.links) ? "true" : "false";
	var is_frames = (window.frames) ? "true" : "false";
	var is_screen = (window.screen) ? "true" : "false";

// java
	var is_java = (navigator.javaEnabled());

// flash detection	
var flashinstalled = 0;
var flashversion = 0;
MSDetect = "false";
if (navigator.plugins && navigator.plugins.length)
{
	x = navigator.plugins["Shockwave Flash"];
	if (x)
	{
		flashinstalled = 2;
		if (x.description)
		{
			y = x.description;
			flashversion = y.charAt(y.indexOf('.')-1);
		}
	}
	else
		flashinstalled = 1;
	if (navigator.plugins["Shockwave Flash 2.0"])
	{
		flashinstalled = 2;
		flashversion = 2;
	}
}
else if (navigator.mimeTypes && navigator.mimeTypes.length)
{
	x = navigator.mimeTypes['application/x-shockwave-flash'];
	if (x && x.enabledPlugin)
		flashinstalled = 2;
	else
		flashinstalled = 1;
}
else
	MSDetect = "true";



//--> end hide JavaScript


function Toggle(sectionArray) 
{ 
	for (var i = 0; i < sectionArray.length; i++) {
		if (sectionArray[i].style.display == "none") {
			(sectionArray[i].style.display = "inline");
		}
		else {
			(sectionArray[i].style.display = "none");
		}
	}
}

function ToggleVis(sectionArray) 
{ 
	for (var i = 0; i < sectionArray.length; i++) {
		if (sectionArray[i].style.visibility == "hidden") {
			(sectionArray[i].style.visibility = "visible");
		}
		else {
			(sectionArray[i].style.visibility = "hidden");
		}
	}
}

function SetFocus() 
{
	document.theForm.itemSubjectLong.focus();
	document.theForm.itemSubjectLong.select();
}

function LinkLoad()
{
	document.location.href = "linkadd.asp?link_name=" + document.title + "&link_url=" + escape( document.location.href )
}

function confirmDelete( smsg, shref ) {
	if (confirm("Are you sure you want to delete this " + smsg + "?"))
		document.location.href = shref;
		}					
	
function loadViewer(sdoc_filename, docId, intPrint, strAllow, strSearch) 
{
	var strFind = "";
	var isPDF = false;
	var printVersion = intPrint;
	intPrint = (parseInt(intPrint)==1 || strAllow=='True' || parseInt(strAllow)==1) ? 1 : 0;
	
	if (document.form1) 
	{ 
	  //*DA* 6/10/2008 added the else if to accommodate the new search page, in which the search_text field is not in the form
	  if (document.form1.search_text) { strFind = document.form1.search_text.value; }
	  else if (document.getElementById('search_text')) { strFind = document.getElementById('search_text').value;	}
	}
	else if (strSearch) { strFind = strSearch; }
	
	if (sdoc_filename.indexOf(".") > -1) 
	{
		if (sdoc_filename.split(".")[1].toLowerCase() == "pdf") isPDF = true;
	}
	if (isPDF)
	{
		//if (docId == 59515) alert(escape(sdoc_filename.replace(/\&apos;/g, "'")));
		viewWindow = window.open("/doc/AdobeViewer.asp?doc_filename=" + escape(sdoc_filename.replace(/\&apos;/g, "'")) + "&sfind=" + strFind + "&print=" + intPrint + "&docid=" + docId, null, 'height=535,width=565,menubar=no,resizable=yes,toolbar=no,scrollbars=yes');
	}
	else
	{
	  var showToolbar = (printVersion == 1) ? 'yes' : 'no';
		viewWindow = window.open("/doc/documentviewer.asp?doc_filename=" + escape(sdoc_filename.replace(/\&apos;/g, "'")) + "&sfind=" + strFind + "&docid=" + docId + "&print=" + printVersion, null, 'height=535,width=565,menubar=' + printVersion + ',location=no,resizable=yes,toolbar=' + showToolbar + ',scrollbars=yes');
		//viewWindow = window.open("/doc/documentviewer.asp?doc_filename=" + escape(sdoc_filename.replace(/\&apos;/g, "'")) + "&sfind=" + strFind + "&docid=" + docId + "&print=" + printVersion, null, 'height=535,width=565,menubar=' + printVersion + ',location=no,resizable=yes,toolbar=no,scrollbars=yes');
	}
	
	viewWindow.focus();
}

function loadWindowNoChrome(sUrl, lHeight, lWidth)
{
	window.open(sUrl, "", "height=" + lHeight + ",width=" + lWidth + ",resizable=yes,status=yes");
}

//function loadWindowLocation(sUrl, lHeight, lWidth)
//{
//	window.open(sUrl, "", "height=" + lHeight + ",width=" + lWidth + ",resizable=yes,status=yes,location=yes");
//}

function loadWindowNoChromeScroll(sUrl, lHeight, lWidth)
{
	window.open(sUrl, "", "height=" + lHeight + ",width=" + lWidth + ",resizable=yes,status=yes,scrollbars=yes");
}

function loadWindow( sWindow, lHeight, lWidth) 
{
	UPWindow = window.open(sWindow,"UpPict","height=" + lHeight + ",width=" + lWidth + ",resizable=yes,status=yes,location=yes");
}

var activeModalWin;
function openModalDialog(url, height, width)
{
	if (window.showModalDialog)
	{		
		//window.showModalDialog(url, window, "dialogHeight: " + height + "px; dialogWidth: " + width + "px; edge: Sunken; center: Yes; help: No; resizable: No; status: No; scroll: No;");
		window.showModalDialog(url, window, "dialogHeight: " + height + "px; dialogWidth: " + width + "px; edge: Sunken; center: Yes; help: No; resizable: Yes; status: No; scroll: No;");
	}
	else
	{
		width = width + 8;
		height = height - 20;
		var left = window.screenX + width/2;
    var top = screen.availHeight/2 - height/2;
    activeModalWin = window.open(url, "", "width="+width+"px,height="+height+",left="+left+",top="+top);
    window.onfocus = function(){if (activeModalWin.closed == false){activeModalWin.focus();};};
  }
}
				
function openModelessDialog(url, height, width, nonModeless)
{
	if (window.showModelessDialog && !nonModeless)
		window.showModelessDialog(url, window, "dialogHeight: " + (parseInt(height) + 35) + "px; dialogWidth: " + (parseInt(width) - 15) + "px; edge: Sunken; center: Yes; help: No; resizable: No; status: No; scroll: No;");
	else
		window.open(url,null,"height=" + height + ",width=" + width + ", location=no, menubar=no, status=no, toolbar=no, scrollbars=yes, resizable=yes");
}

function openWindow(url) 
	{
	popupWin = window.open(url, 'Child')
	}

function loadPictureWindow( sParm ) 
{
	if (document.form1 != null) 
	{
		if (document.form1.picture_file != null) 
		{
      var idx = sParm.lastIndexOf( "picture=" );
			if (idx > 0) sParm = sParm.substring( 0, idx );
			
			sParm += "picture=";
			sParm += (document.form1.picture_file.value.indexOf('%') > -1) ? document.form1.picture_file.value : escape(document.form1.picture_file.value);
			sParm += "&allow_resize_flag=" + escape(document.form1.allow_resize_flag.value);
			sParm += "&caption=";
			sParm += (document.form1.caption.value.indexOf('%') > -1) ? document.form1.caption.value : escape(document.form1.caption.value);
		}
	}

	loadWindow( sPrefix + "member/UploadPic.asp?" + sParm, 280, 650 )
}
	
function loadAddressWindow( sParm ) {
	loadWindow( sPrefix + "member/memberaddress.asp?" + sParm, 400, 300 )
}

function loadCommWindow( sParm ) {
	loadWindow( sPrefix + "member/membercomm.asp?" + sParm, 200, 600 )
		}

function loadEmergencyWindow( sParm ) {
	loadWindow( sPrefix + "member/memberemergency.asp?" + sParm, 280, 650 )
		}

function loadPetWindow( sParm ) {
	loadWindow( sPrefix + "member/memberpet.asp?" + sParm, 400, 600 )
}

function closeWindow() {
   UPWindow.close();
} 

function loadWindowAdd(sdoc_parent_id) {
	var swin = '/doc/documentFolderAdd.asp';
	if (sdoc_parent_id)
		swin = swin + '?doc_parent_id=' + sdoc_parent_id;
	
   docWindow = window.open(swin,'DocFolder','height=540,width=680,scrollbars=yes,resizable=yes');
} 

function loadWindowMeta() 
{
	var swin = '/link/WebPublisher_Adv.asp';
	docMeta = window.open(swin,'DocFolder','height=440,width=600,scrollbars=yes,resizable=yes');
} 

function loadPrintWindow(link_id, assn_id) 
{
	var sFile = '/link/linkshow.asp?link_id=' + link_id + '&assn_id=' + assn_id + '&ptype=print';
	printWin = window.open(sFile);
}

function openPopupWin(url, height, width, winName)
{
	if (1==2) //(document.all || document.getElementById)
	{
		window.showModalDialog(url,"","dialogHeight: " + (parseInt(height) + 25) + "px; dialogWidth: " + (parseInt(width) + 20) + "px; dialogTop: px; dialogLeft: px; edge: Sunken; center: Yes; help: No; resizable: No; status: No;");
	}
	else
	{
		newWin = window.open(url,winName,"height=" + height + ",width=" + width + ",resizable=yes,status=no,location=no,menubar=no");
	}
}

function loadAdobeWindow() 
{
	adobeWin = window.open('http://www.adobe.com/products/acrobat/readstep2.html', null, 'height=590,width=780,menubar=yes,resizable=yes,scrollbars=yes');
	adobeWin.focus();
}

function loadDownload(sdoc_filename, doc_id) 
{
  //window.open("/doc/documentdownload.asp?doc_filename=" + escape(sdoc_filename), "d" + lid, 'height=400,width=500,menubar=yes,resizable=yes,scrollbars=yes');
  if (sdoc_filename.length > 0) 
		{document.location.href = "/doc/Download.asp?doc_filename=" + escape(sdoc_filename);}
	else
		{document.location.href = "/doc/Download.asp?doc_id=" + doc_id;
		}
}

function showMap(strMap)
{
	var strURL = "/Maps/MicrosoftMaps.htm?t=" + escape(strMap);
	window.open(strURL,null,"height=400,width=600, location=no, menubar=yes, status=no, toolbar=no, scrollbars=yes, resizable=yes");
}
	
function flashWrite(width, height, flashPath, assnName, logoPath, flashVersion, secure)
{
	var MM_contentVersion = 5;
	if (flashVersion == '6,0,0,0') MM_contentVersion = 6;
		
	var plugin = (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"]) ? navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : 0;
	if ( plugin ) 
	{
		var words = navigator.plugins["Shockwave Flash"].description.split(" ");
	  for (var i = 0; i < words.length; ++i)
	  {
			if (isNaN(parseInt(words[i])))
			continue;
			var MM_PluginVersion = words[i]; 
	  }
		var MM_FlashCanPlay = MM_PluginVersion >= MM_contentVersion;
	}
	else if (navigator.userAgent && navigator.userAgent.indexOf("MSIE")>=0 && (navigator.appVersion.indexOf("Win") != -1)) 
	{
		document.write('<SCR' + 'IPT LANGUAGE=VBScript\> \n'); //FS hide this from IE4.5 Mac by splitting the tag
		document.write('on error resume next \n');
		document.write('MM_FlashCanPlay = ( IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash." & MM_contentVersion)))\n');
		document.write('</SCR' + 'IPT\> \n');
	}

	if (MM_FlashCanPlay || (is_ie && is_win)) 
	{
		if (flashVersion == '') flashVersion = "5,0,0,0";
			
		var strOut = '<div align="left" id="headerHide">';
		if (secure)
			strOut += '\n<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="https://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=' + flashVersion + '"';
		else
			strOut += '\n<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=' + flashVersion + '"';
		
		strOut += '\nwidth="' + width + '" height="' + height + '" align="left">';
		strOut += '\n<param name="movie" value="' + flashPath + '?assn_name=' + assnName + '" />';
		strOut += '\n<param name="quality" value="high" /><param name="BGCOLOR" value="white" />'
		if (secure)
			strOut += '\n<embed src="' + flashPath + '?assn_name=' + assnName + '" quality="high" pluginspage="https://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="' + width + '" height="' + height + '">';
		else
			strOut += '\n<embed src="' + flashPath + '?assn_name=' + assnName + '" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="' + width + '" height="' + height + '">';
		
		strOut += '\n</embed></object></div>';
		
		//if (flashVersion == '6,0,0,0' && is_nav) alert(strOut);
		document.write(strOut);
	}
	else
	{
		document.write('<td class="clsLogoImage" title="homeowners association management software."><img alt="homeowners association management software." src="' + logoPath + '"/></td>');
	}
}

function flashWrite2(width, height, flashPath, assnName, logoPath, flashVersion, secure)
{
	if (flashVersion == '') flashVersion = "6,0,0,0";
	var strOut = '<div style="position:relative; height:' + height + 'px; width:' + width + 'px;">';
	
	if (flashPath)
	{		
		strOut += '<div align="left" id="headerHide" style="position:absolute; top:0px; left:0px; z-index=2">';
		if (secure)
			strOut += '\n<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="https://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=' + flashVersion + '"';
		else
			strOut += '\n<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=' + flashVersion + '"';
			
		strOut += '\nwidth="' + width + '" height="' + height + '" align="left">';
		strOut += '\n<param name="movie" value="' + flashPath + '?assn_name=' + assnName + '" />';
		strOut += '\n<param name="quality" value="high" /><param name="BGCOLOR" value="white" />'
		if (secure)
			strOut += '\n<embed src="' + flashPath + '?assn_name=' + assnName + '" quality="high" pluginspage="https://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="' + width + '" height="' + height + '">';
		else
			strOut += '\n<embed src="' + flashPath + '?assn_name=' + assnName + '" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="' + width + '" height="' + height + '">';
		
		strOut += '\n</embed></object></div>';
	}
	
	//logo image
	strOut += '<div class="clsLogoImage" title="homeowners association management software." style="position:absolute; top:0px; left:0px; z-index=1">';
	strOut += '<img alt="homeowners association management software." src="' + logoPath + '"/></div>';	
	
	strOut += '</div>';
	//if (flashVersion == '6,0,0,0' && is_nav) alert(strOut);
	document.write(strOut);
}

function formatCurrency(num) 
{
	var isNegative = false;
	num = num.toString().replace(/[$]|[,]/g,'');
	
	if(isNaN(num)) {num = "0";}
  if ( num < 0 ) 
  {
    num = Math.abs(num);
    isNegative = true;
  }
  
  var cents = Math.floor((num * 100 + 0.5) % 100);
  num = Math.floor((num * 100 + 0.5) / 100).toString();
	
	if (cents < 10) {cents = "0" + cents;}
  
  for (i = 0; i < Math.floor((num.length - (1 + i)) / 3); i++) 
  {
		num = num.substring(0 ,num.length - (4 * i + 3)) + ',' + num.substring(num.length - (4 * i + 3));
	}

  var result = num + '.' + cents;
  
  if (isNegative) {result = "-" + result;}
  
  return result;
}

var bolSelectsHidden = false;
function hideSelects()
{
	// Hide all select elements
	bolSelectsHidden = true;
  var selCol = document.getElementsByTagName("SELECT");
  var selId;

  for (var i=0; i<selCol.length; i++)
  {
		selId = selCol[i].id;
		if (selId != 'popCalMonth' && selId != 'popCalYear') 
		{
			selCol[i].style.visibility = "hidden";
		}
	}
	
	// Hide Flash Objects
	selCol = document.getElementsByTagName("OBJECT");
  for (var i=0; i<selCol.length; i++)
  {
		selId = selCol[i].id;
		if (selId != 'swfObj' && selId != 'swfEmbed') { selCol[i].style.visibility = "hidden"; }
	}
}

function showSelects()
{
	if (bolSelectsHidden)
	{
		var selCol = document.getElementsByTagName("SELECT");
		var selId;
		for (var i=0; i<selCol.length; i++)
		{
			selId = selCol[i].id;
			if (selId != 'popCalMonth' && selId != 'popCalYear') 
			{
				selCol[i].style.visibility = "visible";
			}
		}
		
		// Show Flash Objects
		selCol = document.getElementsByTagName("OBJECT");
		for (var i=0; i<selCol.length; i++)
		{
			selId = selCol[i].id;
		if (selId != 'swfObj' && selId != 'swfEmbed') { selCol[i].style.visibility = "visible";	}
		}
	}
	bolSelectsHidden = false;
}

function noSelects()
{
	// Hide all select elements
  var selCol = document.getElementsByTagName("SELECT");
  var selId;

  for (var i=0; i<selCol.length; i++)
  {
		selId = selCol[i].id;
		if (selId != 'popCalMonth' && selId != 'popCalYear') 
		{
			selCol[i].style.display = "none";
		}
	}
}

function yesSelects()
{
	var selCol = document.getElementsByTagName("SELECT");
	var selId;
	for (var i=0; i<selCol.length; i++)
	{
		selId = selCol[i].id;
		if (selId != 'popCalMonth' && selId != 'popCalYear') 
		{
			selCol[i].style.display = "inline";
		}
	}
}

function getIframDoc(sId)
{
	var d = document;
	return d.frames ? d.frames[sId] : d.getElementById(sId).contentWindow;
}

// Page Query =====================================================================================
function PageQuery(q) 
{
	if(q.length > 1) 
	{ 
		if (q.substr(0,1) == '?') this.q = q.substring(1, q.length); 
		else this.q = q;
	}
	else this.q = null;
	
	this.keyValuePairs = new Array();
	if(q) 
	{
		for(var i=0; i < this.q.split("&").length; i++) 
		{
			this.keyValuePairs[i] = this.q.split("&")[i];
		}
	}

	this.getKeyValuePairs = function() { return this.keyValuePairs; }
	
	this.getValue = function(s) 
	{
		for(var j=0; j < this.keyValuePairs.length; j++) 
		{
			if(this.keyValuePairs[j].split("=")[0] == s) return this.keyValuePairs[j].split("=")[1];
		}
		return -1;
	}
	
	this.setValue = function(key, val)
	{
	  for(var j=0; j < this.keyValuePairs.length; j++) 
		{
			if(this.keyValuePairs[j].split("=")[0] == key) 
			{
			  this.keyValuePairs[j] = key + "=" + val;
			  return;
			}
		}
		this.keyValuePairs[this.keyValuePairs.length] = key + "=" + val;
	}
	
	this.getParameters = function() 
	{
		var a = new Array(this.getLength());
		for(var j=0; j < this.keyValuePairs.length; j++) 
		{
			a[j] = this.keyValuePairs[j].split("=")[0];
		}
		return a;
	}
	
	this.getLength = function() { return this.keyValuePairs.length; }	
	
	this.buildQueryString = function() {return this.keyValuePairs.join("&"); }
}

function xmlEscape(strIn)
{
	var strOut = strIn.replace(/[&]/g, '&amp;');
	strOut = strOut.replace(/[>]/g, '&gt;');
	strOut = strOut.replace(/[<]/g, '&lt;');
	strOut = strOut.replace(/["]/g, '&quot;');
	
	return strOut
}

// Set Focus ======================================================================================
var _setFocusMaxTries = 0;
function setFocus(elName)
{
	_setFocusMaxTries++;
	var objEl = document.getElementById(elName);
	if (objEl)
	{
		try { objEl.focus(); _setFocusMaxTries = 0; return;}
		catch(e) { if (_setFocusMaxTries < 5) window.setTimeout("setFocus('" + elName + "')", 50); }
	}
	if (_setFocusMaxTries < 5) window.setTimeout("setFocus('" + elName + "')", 50);
}

// String Functions ===============================================================================
function leftTrim(sString) 
{
	if (sString.length == 0) return "";
	while (sString.substring(0,1) == ' ')
	{
		sString = sString.substring(1, sString.length);
	}
	return sString;
}

function rightTrim(sString) 
{
	if (sString.length == 0) return "";
	while (sString.substring(sString.length-1, sString.length) == ' ')
	{
		sString = sString.substring(0,sString.length-1);
	}
	return sString;
}

function Trim(sString)
{
	return rightTrim(leftTrim(sString));
}

// Regular Expression Field Validations ===========================================================

// Currency
var reCurrency = /^((\d+(\.\d{0,2})?)|((\d*\.)?\d{1,2}))$/; 

// Matches any anthing thats not a decimal or digit
var reNonFloat = /[^\d\.]/g;

// Matches and new line, return, or tab character
var reWhiteSpace = /\n|\r|\t/g;

// Email - one or more characters, followed by @, followed by one or more characters, followed by ., 
// followed by one or more characters
var reEmail = /^.+\@.+\..+$/;

// matches ( ) &lt; &gt; [ ] , ; : \ / "
var reEmailIllegalChars= /[\(\)\<\>\,\;\:\\\/\"\[\]\s]/;

// one or more digits
var reInteger = /^\d+$/;

// Date Validation
var daysInMonth = new Array(12);
daysInMonth[0] = 31;
daysInMonth[1] = 29;   // must programmatically check this
daysInMonth[2] = 31;
daysInMonth[3] = 30;
daysInMonth[4] = 31;
daysInMonth[5] = 30;
daysInMonth[6] = 31;
daysInMonth[7] = 31;
daysInMonth[8] = 30;
daysInMonth[9] = 31;
daysInMonth[10] = 30;
daysInMonth[11] = 31;

function isDate(strDate)
{
	var arDateParts = strDate.split("/");
	if (arDateParts.length != 3) return false;
	
	var year = parseInt(arDateParts[2]);
	var month = parseInt(arDateParts[0]);
	var day = parseInt(arDateParts[1]);
	
	if (year < 1900 || year > 2100) return false;
	
	daysInMonth[1] = ((year % 4 == 0) && ( !(year % 100 == 0) || (year % 400 == 0) ) ? 29 : 28);
	if (month < 1 || month > 12) return false;
	
	if (day < 1 || day > daysInMonth[month -1]) return false;
	
	return true;
}

function isEmailAddr(strEmail)
{
	return reEmail.test(strEmail) && !reEmailIllegalChars.test(strEmail);
}

function escQuotes(strXML)
{
	return strXML.replace(/"/g, '~&~');
}

//Debug Flags - controls weather errors are displayed in the log function
var gbolDebugEditor = false;
var strDocUrl = document.URL;
if (strDocUrl.indexOf("debug=true") > 0) gbolDebugEditor = true;

function log(e, strFunctionName)
{
  try
  {
    if(typeof(strFunctionName) == "undefined")
      strFunctionName = "";
      
    if(typeof(e) == "object")
    {
      var str = strFunctionName + ": " + e.message;
      var name = e.name;
    } 
    else
    {
      var str = strFunctionName + ": " + e;
      var name = "";
    }
    
    if(gbolDebugEditor)
    {
      var oTxt = document.getElementById("txtDebug");
      
      if(!oTxt)
      {
        oTxt                    = document.createElement('textarea');
        oTxt.id                 = 'txtDebug';
        oTxt.style.position     = 'absolute';
        oTxt.style.left         = '10px';
        oTxt.style.bottom       = '35px';
        oTxt.style.height       = '170px';
        oTxt.style.width        = '250px';
        oTxt.style.overflow     = 'auto';
        oTxt.style.visibility   = 'visible';
        oTxt.style.zIndex       = '1000';
        
        document.body.appendChild(oTxt);

      } 
      oTxt.value += str + " (" + name + ")" + "\n\n";
      try {oTxt.doScroll("scrollbarPageDown");}
      catch (z) {}
      
    } 
  } 
  catch(f)
  {
    alert("An unhandled exception has occurred.  Press F5 to reload the application.");
  }
}

// ========================================================
//EXAMPLE (with "AttachEvent" function):
//  AttachEvent(document, "keypress", captureEnter, false);
//  function captureEnterFunction() { alert("function"); }
function captureEnter(e)
{
  if (!e) { e = window.event; }
  var iKey = (typeof e.which == 'number') ? e.which : e.keyCode;
  if (iKey == 13) { captureEnterFunction(); }
}

//***Cross browser attach event function. For 'evt' pass a string value with the leading "on" omitted
//***e.g. AttachEvent(window,'load',MyFunctionNameWithoutParenthesis,false);
function AttachEvent(obj,evt,fnc,useCapture)
{
	if (!useCapture) { useCapture=false; }
	if (obj)
	{
	  if (obj.addEventListener) { obj.addEventListener(evt,fnc,useCapture); return true; }
	  else if (obj.attachEvent) { return obj.attachEvent("on"+evt,fnc); }
	  else { MyAttachEvent(obj,evt,fnc); obj['on'+evt]=function(){ MyFireEvent(obj,evt) }; }
  }
} 
//The following are for browsers like NS4 or IE5Mac which don't support either attachEvent or addEventListener
function MyAttachEvent(obj,evt,fnc)
{
	if (!obj.myEvents) obj.myEvents={};
	if (!obj.myEvents[evt]) obj.myEvents[evt]=[];
	var evts = obj.myEvents[evt];
	evts[evts.length]=fnc;
}
function MyFireEvent(obj,evt)
{
	if (!obj || !obj.myEvents || !obj.myEvents[evt]) { return; }
	var evts = obj.myEvents[evt];
	for (var i=0,len=evts.length;i<len;i++) evts[i]();
}

/* Ext based page getter class ==================================================================== */
AV.PageGetter = function()
{
	// constructor
	this.init = function(pageURL, domID)
	{
		var conn = new Ext.data.Connection();
		conn.on('requestcomplete', function(o,response,options) {
			//var strProps = "";
			//for (var prop in response) strProps += prop + ": " + response[prop] + "\n";
			var strResp = response.responseText;
			
			// Pull everything in the response between the content tags
			var iStart = strResp.indexOf("<Content>") + 9
			var iEnd = strResp.indexOf("</Content>");
			var strOut = strResp.substring(iStart, iEnd);
			
			// Strip out any script tags and just write the html to the div
			var reStrip = /<script.*?>(\n|\r|.)*?<\/script>/img;
			Ext.get(domID).dom.innerHTML = strOut.replace(reStrip, '');
			
			// Grab the scripts and add them to the head tag
			var hd = document.getElementsByTagName("head")[0];
      var re = /(?:<script([^>]*)?>)((\n|\r|.)*?)(?:<\/script>)/img;
      var srcRe = /\ssrc=([\'\"])(.*?)\1/i;
      var match;
      while(match = re.exec(strOut))
      {
				var srcMatch = match[1] ? match[1].match(srcRe) : false;
        if(srcMatch && srcMatch[2])
        {
					var s = document.createElement("script");
          s.src = srcMatch[2];
          hd.appendChild(s);
         }
         else if(match[2] && match[2].length > 0)
         {
					eval(match[2]);
         }
      }

    });
		
		conn.request({
        url: pageURL, // + "?t=" + new Date().getMilliseconds(),
        scripts:false,
        scope:this			
    });
	}
}

/* Script and CSS loading ========================================================================= */
function loadJS(strUrl, useDocWrite)
{
	if (useDocWrite)
	{
		document.write('<s' + 'cript type="text/javascript" src="' + strUrl + '"></s' + "cript>");
	}
	else
	{
		var arScripts = document.getElementsByTagName("script");
		var intScriptLen = strUrl.length;
		
		for (var i=0; i<arScripts.length; i++)
		{
			var strScript = arScripts[i].src.toLowerCase()
			var iLen = strScript.length;	
			if (iLen > 0 && iLen > intScriptLen) strScript = strScript.substr(iLen -	intScriptLen)
			if (strScript == strUrl.toLowerCase()) return;
		}

		var e = document.createElement("script");
		e.src = strUrl;
		e.type = "text/javascript";
		document.getElementsByTagName("head")[0].appendChild(e); 
	}
}

function loadCSS(strUrl, useDocWrite)
{
	if (useDocWrite)
	{
		document.write('<l' + 'ink rel="stylesheet" type="text/css" href="' + strUrl + ' "/>');
	}
	else
	{
		var arCss = document.getElementsByTagName("link");
		var intScriptLen = strUrl.length;
		
		for (var i=0; i<arCss.length; i++)
		{
			var strScript = arCss[i].href.toLowerCase()
			var iLen = strScript.length;	
			if (iLen > 0 && iLen > intScriptLen) strScript = strScript.substr(iLen -	intScriptLen)
			if (strScript == strUrl.toLowerCase()) return;
		}
		 
		var e = document.createElement("link");
		e.href = strUrl;
		e.type = "text/css";
		e.rel = "stylesheet"
		document.getElementsByTagName("head")[0].appendChild(e);
	}
}

function loadExt(ExtBaseUrl, YahooBaseUrl, useYahoo, debug)
{
	Ext = null;
	//if (!YahooBaseUrl) YahooBaseUrl = '/library/Yahoo/Current/';
	if (!ExtBaseUrl) ExtBaseUrl = '/Library/Ext/Current/';
	
	// Load CSS
	loadCSS(ExtBaseUrl + 'resources/css/ext-all.css', is_ie);
	loadCSS(ExtBaseUrl + 'resources/css/xtheme-gray.css', is_ie);
	
	// Yahoo base library or EXT base
	if (useYahoo)	
	{ 
		if (!YahooBaseUrl) { loadJS(ExtBaseUrl + 'adapter/yui/yui-utilities.js', is_ie); }
		else { loadJS(YahooBaseUrl + 'yahoo-dom-event/yahoo-dom-event.js', is_ie); }	
		//loadJS(YahooBaseUrl + 'build/yahoo-dom-event/yahoo-dom-event.js', is_ie); 
		loadJS(ExtBaseUrl + 'adapter/yui/ext-yui-adapter.js', is_ie); 
	}
	else 
	{ 
		loadJS(ExtBaseUrl + 'adapter/ext/ext-base.js', is_ie); 
	}
	
	// Full EXT lib
	loadJS(ExtBaseUrl + 'ext-all' + (debug ? '-debug' : '') + '.js', is_ie);
	loadExtOnLoad(setExtBlankImg);
}

function setExtBlankImg()
{
	Ext.BLANK_IMAGE_URL = "/images/1ptrans.gif";
}

function loadExtOnLoad(fn)
{
	 if (Ext) fn.call();
	 else setTimeout('loadExtOnLoad(' + fn + ')', 50);
}

// Dom Helper Methods	=============================================================================
function boxDimensions()
{
	this.left		= 0;
	this.top		= 0;
	this.width	= 0;
	this.height = 0;
}

function findElDimensions(el) 
{
	var obj;
	if (typeof(el) == 'object') obj = el;
	else obj = document.getElementById(el);
	var box = new boxDimensions();
	
	box.width = obj.offsetWidth;
	box.height = obj.offsetHeight;

	var curleft = curtop = 0;
	if (obj.offsetParent) 
	{
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) 
		{
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	box.top = curtop;
	box.left = curleft;
	return box;
}

// IN PAGE Help ===================================================================================
function loadInPageHelp()
{
  var helpDiv;
  if(Ext.isReady == true)
  {      
    if(Ext.get("divHelp"))
    {    
      helpDiv = new Ext.Panel({
        title: '<a href="javascript:openPopupWin(\'/Help/ASPTOASPX.asp\', 600, 800, \'help\');">Help</a>',
        collapsible: true,
        applyTo: Ext.get("divHelp"),    
        contentEl: "divHelpContent",    //The id of an existing HTML node to use as the panel's body content (defaults to ''). 
        autoScroll: true,      
        collapsed: false,
        titleCollapse: false,
        iconCls: 'help-icon',
        bodyStyle: 'background:transparent;',
        width: '100%',
        height: 200
      });  
      
      //override the css class '.x-panel-header-text', to correspond with AV style
      Ext.get('divHelp').dom.firstChild.lastChild.className = 'clsBodyText';
      //Ext.get('divHelp').dom.firstChild.lastChild.className = 'clsCaption';
      //helpDiv.header.on('click', function() { openPopupWin('/Help/ASPTOASPX.asp', 600, 800); });
      //helpDiv.header.dom.childNodes[1].on('click', function() { openPopupWin('/Help/ASPTOASPX.asp', 600, 800); });
      helpDiv.header.dom.childNodes[1].onclick = function() {openPopupWin('/Help/ASPTOASPX.asp', 600, 800, 'help'); }
      helpDiv.header.dom.childNodes[1].onmouseover = function() { this.style.cursor='hand'; }
    }
  }
}

//HEADER SEARCH =====================================================================
function doHeaderSearch()
{	 
	if (document.getElementById('header_search_text').value != '' && document.getElementById('header_search_text').className != 'clsSearchInput')
		document.location.href = '/Search.asp?search_text_for_submit=' + escape(AV.NoiseWords.remove(document.getElementById('header_search_text').value)) + '&search_members=1&search_events=1&search_forms=1&search_classifieds=1&search_announcements=1&search_docs=1&search_docs_cat=&search_weblinks=1&search_posts=1';		
}

function clearDefault(el) 
{
  if (el.defaultValue==el.value && el.className=='clsSearchInput') el.value = "";
}

function getDefaultValue(el) 
{
 if(el.value == '')
 {
  el.value = el.defaultValue;
  el.className='clsSearchInput';
 }
}

function headerSearch_keyCapture(e)
{

  e = e || window.event;    
  var code = e.keyCode || e.which;    
  if(code == 13)
    doHeaderSearch(); 

}

AV.NoiseWords = new function()
{
  return {
  
    remove: function(phrase)
    {
      var arNoise = ['about','1','after','2','all','also','3','an','4','~and~','5','another','6','any','7',
      'are','8','as','9','at','0','be','$','because','been','before','being','between','both','but','by','came',
      'can','come','could','did','do','each','for','from','get','got','has','had','he','have','her','here','him',
      'himself','his','how','if','in','into','is','it','like','make','many','me','might','more','most','much','must',
      'my','never','now','of','on','only','~or~','other','our','out','over','said','same','see','should','since','some',
      'still','such','take','than','that','the','their','them','then','there','these','they','this','those','through',
      'to','too','under','up','very','was','way','we','well','were','what','where','which','while','who','with','would',
      'you','your','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'];
      var iNoiseLen = arNoise.length;
    	
      var arParts = phrase.split(' ');      	
      var arKeepers = new Array();
      var inQuotes = false;
      var keep = true;
    	
      // Remove noise words only if they are not contained in an exact phrase (quotes)	   	       
      for(var ix=0; ix < arParts.length; ix++)
      {
        //is the word inside quotes?
        if(arParts[ix].indexOf('"') != -1) 
        { 
          if(inQuotes) { inQuotes = false }
          else { inQuotes = true; }            
        }
        
        keep = true;
        
        for (var i=0; i<iNoiseLen; i++)
        {          
          if(arParts[ix].toUpperCase() == arNoise[i].toUpperCase() && !inQuotes) { keep = false; }
        }
        
        if(keep) { arKeepers.push(arParts[ix]); }
      }
        	          
      return arKeepers.join(' ');	
    }
  }	      	
}  

//==========================================
AV.Ascii = new function()
{
  return  {
    
      removeSpecial: function(sText)
      {
        /* STIP away characters commonly pasted from MS word.  (some email clients do not display
          them properly.
        8211	en dash
        8212	em dash
        8216	left single quotation mark
        8217	right single quotation mark
        8226	bullet
        8220  left double quote (smart quote)
        8221  right double quote (smart quote)
        2018  left single quotation mark
        2019  right single quotation mark
        */
        var unicodeValues = new Array(8217, 8216, 8212, 8211, 8226, 8220, 8221, 2018, 2019);
        var replaceValues = new Array("'", "'", "-", "--", "*", '"', '"', "'", "'");
        
        for(var i=0; i<unicodeValues.length; i++)
          { sText = sText.replace(String.fromCharCode(unicodeValues[i]), replaceValues[i]); }
        
        return sText;
      }      
  }
}

//RSS=================================================================

function writeRssHeaderLink(href, title)
{
	var newLink = document.createElement('link');
	newLink.type = 'application/rss+xml';
	newLink.href = href;
	newLink.rel = 'alternate';
	newLink.title = title;
	document.getElementsByTagName("head")[0].appendChild(newLink);
}
